package model

import (
	"context"
	"gitee.com/ai-love-save/ai-love-save-back/internal/dao"
	"gitee.com/ai-love-save/ai-love-save-back/internal/schema"
	"github.com/google/wire"
	"github.com/jinzhu/copier"
)

// MenuModelSet Menu model set
var MenuModelSet = wire.NewSet(wire.Struct(new(MenuModel), "*"))

// MenuModel model 层的学院操作结构体
type MenuModel struct {
	MenuDao *dao.MenuDao
}

// QueryMenu  Model menu 查询
func (m *MenuModel) QueryMenu(ctx context.Context, authority int) (*[]schema.QueryMenuHandlerResBodySchema, error) {
	res, err := m.MenuDao.MenuQuery(ctx, authority)
	if err != nil {
		return nil, err
	}
	info := new([]schema.QueryMenuHandlerResBodySchema)

	err = copier.Copy(info, res)
	if err != nil {
		return nil, err
	}

	return info, nil
}
